package view;



import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

public class MenuFrame extends JMenuBar {

	private static final long serialVersionUID = 1L;
	
	private JMenu menuFichier = new JMenu("File");
	private JMenu menuEdition = new JMenu("Edit");
		
	private JMenuItem itemOuvrir = new JMenuItem("Open");
	private JMenuItem itemFermer = new JMenuItem("Close");
	private JMenuItem itemQuitter = new JMenuItem("Quit");
	private JMenuItem itemAnnuler = new JMenuItem("Undo");
	private JMenuItem itemRefaire = new JMenuItem("Redo");
	private JMenuItem itemCouper = new JMenuItem("Cut");
	private JMenuItem itemCopier = new JMenuItem("Copy");
	private JMenuItem itemColler = new JMenuItem("Paste");
	
	public MenuFrame(){
		
		// regler les raccourcis
		menuFichier.setMnemonic('F');
		menuEdition.setMnemonic('E');
		itemOuvrir.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK));
		itemQuitter.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_DOWN_MASK));
		itemAnnuler.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_DOWN_MASK));
		itemColler.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK));
		itemCopier.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK));
		itemCouper.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_DOWN_MASK));
		itemRefaire.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_DOWN_MASK));
		
				
		// items pour le menu Fichier
		menuFichier.add(itemOuvrir);
		menuFichier.add(itemFermer);
		menuFichier.add(itemQuitter);
				
		// items pour le menu Edition
		menuEdition.add(itemAnnuler);
		menuEdition.add(itemRefaire);
		menuEdition.addSeparator();
		menuEdition.add(itemCouper);
		menuEdition.add(itemCopier);
		menuEdition.add(itemColler);
				
		add(menuFichier);
		add(menuEdition);
		
	}
	
	public void addOuvrirMenuListener(ActionListener listener) {
		itemOuvrir.addActionListener(listener);
	}
	
	public void addFermerMenuListener(ActionListener listener) {
		itemFermer.addActionListener(listener);
	}
	
	public void addQuitterMenuListener(ActionListener listener) {
		itemQuitter.addActionListener(listener);
	}
	
	public void addAnnulerMenuListener(ActionListener listener) {
		itemAnnuler.addActionListener(listener);
	}
	
	public void addRefaireMenuListener(ActionListener listener) {
		itemRefaire.addActionListener(listener);
	}
	
	public void addCopierMenuListener(ActionListener listener) {
		itemCopier.addActionListener(listener);
	}
	
	public void addCollerMenuListener(ActionListener listener) {
		itemColler.addActionListener(listener);
	}
	
	public void addCouperMenuListener(ActionListener listener) {
		itemCouper.addActionListener(listener);
	}
}

